package com.per.mybootall.test;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: yyy
 * Date: 2021/11/22
 * Time: 14:01
 * Description:交并补集合
 */
public class test01 {
    public static void main(String[] args) {
        Set<HashMap> result = new HashSet<HashMap>();
        Set<HashMap> set1 = new HashSet<HashMap>() {
            {
                add(new HashMap(){{put("st","2022-03-01");put("en","2022-03-31");}});
                add(new HashMap(){{put("st","2022-04-01");put("en","2022-04-30");}});
            }
        };

        Set<HashMap> set2 = new HashSet<HashMap>() {
            {
                add(new HashMap(){{put("st","2022-03-01");put("en","2022-03-31");}});
                add(new HashMap(){{put("st","2022-04-01");put("en","2022-04-30");}});
                add(new HashMap(){{put("st","2022-05-01");put("en","2022-05-31");}});
            }
        };

//        result.clear();
//        result.addAll(set1);
//        result.retainAll(set2);
//        System.out.println("交集：" + result);

        result.clear();
        result.addAll(set2);
        result.removeAll(set1);
        System.out.println("差集：" + result);

//        result.clear();
//        result.addAll(set1);
//        result.addAll(set2);
//        System.out.println("并集：" + result);

    }
}
